<!doctype html>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<script src="/js/jquery.min.js"></script>
	<link rel="stylesheet" type="text/css" href="/css/bootstrap.css" />
	<script src="/js/bootstrap.js"></script>
	<link rel="stylesheet" type="text/css" href="/css/admin/admincss.css" />
	<title>@yield('title')</title>
	<style type="text/css">
		html,body{
			font-family: "微软雅黑";
		}
	</style>
</head>
<body>
	
	<div class="pages">
		<!-- header part -->
		<div class="header">
			<div class="headerLeft">汉斯顿后台数据管理平台</div>
			<div class="headerRight">
				<div>
					<span>欢迎您：</span>
	                <span class="AccountName">{{ $user->username }}</span>
				</div>
				<div class="btn modifyPassword">
					<p class="modifyLogo"></p>
					<p >修改密码</p>
				</div>
				<div class="btn bowOut">
					<p class="bowoutLogo"></p>
					<p style="margin-left: 25px;">退出</p>
				</div>
			</div>
		</div>
		<!-- content part -->
		<div class="content">
			<!-- contentLeft part -->
			<div class="contentLeft">
				<div class="logoBox"><img src="/img/admin/logoPic.png" /></div>
				<ul class="menuList">
					<a class="devicelist" href="/admin/device/index">
						<img src="/img/admin/deviceListLogo.png" />设备列表
					</a>
					<a class="customers" href="/admin/user/customers">
						<img src="/img/admin/userInfoLogo.png" />用户信息
					</a>
					<a class="index" href="/admin/user/index">
						<img src="/img/admin/accountManageLogo.png" />账号管理
					</a>
				</ul>
			</div>
			<!-- contentRight part -->
			<div class="contentRight">
				<div class="itemText">
					<span class="spanFirst">当前位置：</span>
	               	@section('firstItem')
					    
					@show
				</div>
				<div class="searchList">
					@section('searchList')

	                @show
				</div>
				<div class="clearfloat"></div> 
				<!-- table part -->
				@section('dataTables')
				
	            @show
	            <!-- page number part -->
	            <div class="rightFooter">
	        	@section('add_div')
			
	       		@show
				@section('page_num')
				
				@show
				</div>
	            @section('infor_promit')
			</div>
			<div class="clearfloat"></div> 
		</div>
		@show
		<!-- 修改密码弹框 -->
		<div class="accountManageBg updatePassword">
			<div class="accountManage" >
				<p class="titleTxt">修改密码</p>
				<div><span>旧密码</span><input class="oddPassword" type="password" placeholder="请输入旧密码" /><label class="required">*</label></div>
				<div><span>新密码</span><input class="newPassword" type="password" placeholder="请输入新密码" /><label class="required">*</label></div>
				<div><span>确认密码</span><input class="confirmPassword" type="password" placeholder="请再输入新密码" /><label class="required">*</label></div>
				<div>

				</div>
				<label class="labelBox" id="updataPWlabelBox"></label>
				<div class="btnBox" >
					<a class="cancelBtn updataPWCancelBtn">取消</a>
					<a class="okBtn updataPWOkBtn">确定</a>
				</div>
			</div>
		</div>
		<!-- 删除维护信息弹框 -->
		<div class="deleteBox" style="display: none;">
			<p>删除</p>
			<div class="titleText">确定删除此条维护信息？</div>
			<div class="btnBox">
				<a class="cancelBtn">取消</a>
				<a class="okBtn">确定</a>
			</div>
		</div>
		<!-- 退出账号弹框 -->
		<div class="deleteBoxBg bowOutBg">
			<div class="deleteBox deleteIInfos">
				<p>退出账号</p>
				<div class="titleText">确定退出此账号？</div>
				<label class="labelBox" id="bowOutLabelBox"></label>
				<div class="btnBox">
					<a class="cancelBtn bowOutCancelBtn">取消</a>
					<a class="okBtn bowOutOkBtn">确定</a>
				</div>

			</div>
		</div>
		<!-- 提示信息框 -->
		<div class="hint_bg">
			<div class="hint_box">
				<p class="hint_text"></p>
				<a class="hint_btn">确定</a>
			</div>
		</div>
	</div>
	<script>
	//服务器提示信息
	function hint(hint){
		if(hint)
		{
			$('.hint_bg').css("display","block");
			$('.hint_bg').height($(window).height());
			$('.hint_text').html(hint);
			$('.hint_btn').click(function(){
				$('.hint_bg').css("display","none");
			});
		}
	}
	//计算左边导航栏高度
	if($("table").height()<$("body").height()-120){
		$(".contentLeft").height($("body").height()-120);
	}else{
		$(".contentLeft").height($(".contentRight").height()-120);
	}
	//修改密码
	$(".modifyPassword").click(function(){
		$(".updatePassword").show();
		//$(".updatePassword").height($(window).height());
		$(".updataPWCancelBtn").unbind('click').click(function(){
			$(".updatePassword").hide();
			$(".oddPassword").val("");
			$(".newPassword").val("");
			$(".confirmPassword").val("");
			$(".labelBox").html("");
		})
		$(".updataPWOkBtn").unbind('click').click(function(){
			if($(".oddPassword").val()==""){
				$("#updataPWlabelBox").html("请输入旧密码");
			}else if($(".oddPassword").val().toString().length<6){
				$("#updataPWlabelBox").html("密码至少为6位字符");
			}else if($(".newPassword").val()==""){
				$("#updataPWlabelBox").html("请输入新密码");
			}else if($(".newPassword").val().toString().length<6){
				$("#updataPWlabelBox").html("新密码长度不能小于6位字符。");
			}else if($(".confirmPassword").val()==""){
				$("#updataPWlabelBox").html("请再次输入新密码");
			}else if($(".newPassword").val()!=$(".confirmPassword").val()){
				$("#updataPWlabelBox").html("新旧密码输入不一致。");
			}else{
				$("#updataPWlabelBox").val("");
				$.ajax({
					url:"/admin/api/user/update-password",
					type:"post",
					dataType:"json",
					data:{
						password:$(".oddPassword").val(),
						new_password:$(".newPassword").val(),
						new_password_confirmation:$(".confirmPassword").val()
					},
					success:function(data){
						if(data.status.errCode==0){
							$("#updataPWlabelBox").html("操作成功。");
							setTimeout(function(){
								$(".updatePassword").hide();
								$(".oddPassword").val("");
								$(".newPassword").val("");
								$(".confirmPassword").val("");
								$("#updataPWlabelBox").html("");
							},5000);
						}else{
							$("#updataPWlabelBox").html(data.status.message);
						}
					}
				})
			}
			
		})
	});
	//退出登录
	$(".bowOut").click(function(){

		$(".bowOutBg").show();
		$(".bowOutBg").height($("body").height());

		$(".bowOutCancelBtn").unbind('click').click(function(){
			$(".bowOutBg").hide();
			$(".labelBox").html("");
		})
		$(".bowOutOkBtn").unbind('click').click(function(){
			$.ajax({
				url:"/admin/api/user/logout",
				type:"post",
				dataType:"json",
				success:function(data){
					if (data.status.errCode==0) {
						window.location.href = "/admin/user/login";
					}else{
						$("#bowOutLabelBox").html(data.status.message);
					}
				}
			})
		})
	});
</script>
</body>
</html>
